//
//  CompanyFirstInfoViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/31.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "CompanyFirstInfoViewController.h"
#import "MineInfoEditWXQRCodeViewController.h"
#import <Photos/Photos.h>
#import <AVFoundation/AVCaptureDevice.h>
#import <AVFoundation/AVMediaFormat.h>
#import "CompanySecondInfoViewController.h"

#import "AppDelegate.h"
#import "IDSelectViewController.h"
#import "PersonalWorkExperienceViewController.h"
#import "PersonalFirstInfoViewController.h"
#import "PersonalEducationInfoViewController.h"
#import "CompanyInfoViewController.h"

@interface CompanyFirstInfoViewController ()<MineInfoEditWXQRCodeViewControllerDelegate, PSSingleRowViewDelegate, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate>
{
    UIScrollView *bottomScrollView;
    
    UIImageView *photoImgView;
    PSSingleRowView *headerPickerView;
    
    NSString *url;
    NSString *pathWXImg;
}
@property (nonatomic, strong) PSCell *nameCell;
@property (nonatomic, strong) PSCell *nicknameCell;
@property (nonatomic, strong) PSCell *departmentCell;
@property (nonatomic, strong) PSCell *positionCell;
//    PSCell *phoneCell;
@property (nonatomic, strong) PSCell *emailCell;
@property (nonatomic, strong) PSCell *companyCell;
@property (nonatomic, strong) PSCell *wxQRCodeCell;
@end

@implementation CompanyFirstInfoViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    [self.navigationController setNavigationBarHidden:NO animated:YES];
    self.navigationController.navigationBarHidden = NO;
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self hiddenKeyboard];
    if (headerPickerView) {
        headerPickerView.hidden = YES;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    url = (UD_GetOForK(isAvatar)?UD_GetOForK(isAvatar):@"");
    pathWXImg = (UD_GetOForK(isWeixin_img)?UD_GetOForK(isWeixin_img):@"");
    
    [self initUI];
}
- (void)initUI {
    self.navigationItem.title = @"创建企业";
    
    if (self.isRegisterPush) {
//        [self.navigationController popViewControllerAnimated:YES];
    } else {
        UIButton *switchBtn = [UIToolsControl initButtonWithFrame:CGRectMake(0, 0, 60*Scale, 44) imageName:nil target:self action:@selector(switchBtnTap) title:@"  我要求职" titleColor:THEMECOLOR_OF_ORANGE];
        switchBtn.titleLabel.font = Font(Font_15);
        UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:switchBtn];
        self.navigationItem.leftBarButtonItem = leftItem;
    }
    
    UIButton *nextBtn = [UIToolsControl initButtonWithFrame:CGRectMake(WIDTH-50*Scale, HeightOfStatusBar+3*Scale, 50*Scale, 36) imageName:nil target:self action:@selector(nextBtnTap) title:@"确定" titleColor:THEMECOLOR_OF_ORANGE];
    nextBtn.titleLabel.font = Font(Font_15);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:nextBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    NSMutableArray *headerArray = [NSMutableArray arrayWithCapacity:0];
    PublicCategoryElementModel *model1 = [[PublicCategoryElementModel alloc] init];
    [model1 setValuesForKeysWithDictionary:@{@"id":@"0", @"name":@"拍摄"}];
    [headerArray addObject:model1];
    PublicCategoryElementModel *model2 = [[PublicCategoryElementModel alloc] init];
    [model2 setValuesForKeysWithDictionary:@{@"id":@"1", @"name":@"相册"}];
    [headerArray addObject:model2];
    headerPickerView = [[PSSingleRowView alloc] initWithData:headerArray target:self];
    headerPickerView.hidden = YES;
    
    bottomScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-HeightOfStatusBarAndNavigationBar)];
    [self.view addSubview:bottomScrollView];
    
    UILabel *topOneLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, 20*Scale, WIDTH, 30*Scale) text:@"比特聘-视频面试，更快、更省心！" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_20];
    topOneLbl.textAlignment = NSTextAlignmentCenter;
    [bottomScrollView addSubview:topOneLbl];
    UILabel *topTwoLbl = [UIToolsControl initLabelWithFrame:CGRectMake(0, EndY(topOneLbl), WIDTH, 20*Scale) text:@"真实、完善、有效的信息更吸引优秀人才" textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_12];
    topTwoLbl.textAlignment = NSTextAlignmentCenter;
    [bottomScrollView addSubview:topTwoLbl];
    
    UILabel *photoTitleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(30*Scale, EndY(topTwoLbl)+20*Scale, WIDTH-60*Scale, PSCellHeight) text:@"头像" textColor:THEMECOLOR_OF_TEXT_333333 font:Font_13];
    [bottomScrollView addSubview:photoTitleLbl];
    [photoTitleLbl borderColor:THEMECOLOR_OF_TEXT_cccccc borderWidth:lineH borderType:BorderSideTypeBottom];
    photoImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ViewWidth(photoTitleLbl)-62*Scale, 4*Scale, 62*Scale, 62*Scale) imageName:@"header_bg"];
    photoImgView.contentMode = UIViewContentModeScaleAspectFill;
    photoImgView.layer.cornerRadius = 31*Scale;
    photoImgView.layer.masksToBounds = YES;
    [photoTitleLbl addSubview:photoImgView];
    UIButton *photoBtn = [UIToolsControl initButtonWithFrame:photoTitleLbl.frame imageName:nil target:self action:@selector(photoBtnTap) title:nil titleColor:nil];
    [bottomScrollView addSubview:photoBtn];
    if (url && url.length) {
        [photoImgView sd_setImageWithURL:[NSURL URLWithString:url]];
    }
    
    __weak __typeof(self)weakSelf = self;
    self.nameCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(photoTitleLbl), ViewWidth(photoTitleLbl), PSCellHeight) title:@"姓名" text:(UD_GetOForK(isUserName)?UD_GetOForK(isUserName):nil) placeholder:@"请输入姓名" cellType:PSCellTypeOfWriteonly];
    self.nameCell.textField.delegate = self;
    [bottomScrollView addSubview:self.nameCell];
    
    self.nicknameCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.nameCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"昵称花名" text:(UD_GetOForK(isNickname)?UD_GetOForK(isNickname):nil) placeholder:@"填写一个您喜欢的称呼，用于隐私保护" cellType:PSCellTypeOfWriteonly];
    self.nicknameCell.textField.delegate = self;
    [bottomScrollView addSubview:self.nicknameCell];
    
    self.departmentCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.nicknameCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"我的部门" text:nil placeholder:@"请填写您的部门" cellType:PSCellTypeOfWriteonly];
    self.departmentCell.textField.delegate = self;
    [bottomScrollView addSubview:self.departmentCell];
    
    self.positionCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.departmentCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"我的职位" text:nil placeholder:@"请填写您的真实职位" cellType:PSCellTypeOfWriteonly];
    self.positionCell.textField.delegate = self;
    [bottomScrollView addSubview:self.positionCell];
    
//    phoneCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(positionCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"我的电话" text:(UD_GetOForK(isMobile)?UD_GetOForK(isMobile):nil) placeholder:@"请填写您的电话" cellType:PSCellTypeOfWriteonly];
//    phoneCell.textField.delegate = self;
//    [bottomScrollView addSubview:phoneCell];
    
    self.emailCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.positionCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"我的邮箱" text:(UD_GetOForK(isEmail)?UD_GetOForK(isEmail):nil) placeholder:@"请填写您的邮箱" cellType:PSCellTypeOfWriteonly];
    self.emailCell.textField.delegate = self;
    [bottomScrollView addSubview:self.emailCell];
    
    self.companyCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.emailCell), ViewWidth(photoTitleLbl), PSCellHeight) title:@"我的公司" text:nil placeholder:@"请填写您的目前任职的公司全称" cellType:PSCellTypeOfWriteonly];
    self.companyCell.textField.delegate = self;
    [bottomScrollView addSubview:self.companyCell];
    
    self.wxQRCodeCell = [[PSCell alloc] initWithFrame:CGRectMake(StartX(photoTitleLbl), EndY(self.companyCell), ViewWidth(self.companyCell), PSCellHeight) title:@"微信二维码" text:(UD_GetOForK(isWeixin)?UD_GetOForK(isWeixin):nil) placeholder:@"请填写微信号并上传二维码（可选填）" cellType:PSCellTypeOfIndicator];
    self.wxQRCodeCell.tap = ^{
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [weakSelf hiddenKeyboard];
        MineInfoEditWXQRCodeViewController *MIEWXVC = [[MineInfoEditWXQRCodeViewController alloc] init];
        MIEWXVC.delegate = strongSelf;
        MIEWXVC.wxID = (UD_GetOForK(isWeixin)?UD_GetOForK(isWeixin):@"");
        MIEWXVC.wxURL = (UD_GetOForK(isWeixin_img)?UD_GetOForK(isWeixin_img):@"");
        [strongSelf.navigationController pushViewController:MIEWXVC animated:YES];
    };
    [bottomScrollView addSubview:self.wxQRCodeCell];
    
    bottomScrollView.contentSize = CGSizeMake(0, EndY(self.wxQRCodeCell)+20*Scale);
}
- (void)nextBtnTap {
    if (url && url.length) {
    } else {
        SVPHUDError(@"请上传头像");
        return;
    }
//    [UIToolsControl resignFirstResponderForTextFieldArray:@[nameCell.textField, nicknameCell.textField, departmentCell.textField, positionCell.textField, phoneCell.textField, emailCell.textField, companyCell.textField]];
    [UIToolsControl resignFirstResponderForTextFieldArray:@[self.nameCell.textField, self.nicknameCell.textField, self.departmentCell.textField, self.positionCell.textField, self.emailCell.textField, self.companyCell.textField]];
    if (self.nameCell.textField.text.length>0) {
        if (self.nicknameCell.textField.text.length>0) {
            if (self.departmentCell.textField.text.length>0) {
                if (self.positionCell.textField.text.length>0) {
//                    if (phoneCell.textField.text.length>0) {
//                        if ([UIToolsControl validatePhoneNumber:phoneCell.textField.text]) {
                            if (self.emailCell.textField.text.length>0) {
                                if ([UIToolsControl validateEmail:self.emailCell.textField.text]) {
                                    if (self.companyCell.textField.text) {
                                        [self updateInfo];
                                    } else {
                                        SVPHUDError(CompanyAlertText);
                                    }
                                } else {
                                    SVPHUDError(EmailOKAlertText);
                                }
                            } else {
                                SVPHUDError(EmailAlertText);
                            }
//                        } else {
//                            SVPHUDError(PhoneNumberOKAlertText);
//                        }
//                    } else {
//                        SVPHUDError(PhoneNumberAlertText);
//                    }
                } else {
                    SVPHUDError(PositionAlertText);
                }
            } else {
                SVPHUDError(DepartmentAlertText);
            }
        } else {
            SVPHUDError(NICKNameAlertText);
        }
    } else {
        SVPHUDError(NameAlertText);
        [self.nameCell.textField becomeFirstResponder];
    }
}
- (void)updateInfo {
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:url forKey:@"avatar"];
    [dic setObject:self.nameCell.textField.text forKey:@"realname"];
    [dic setObject:self.nicknameCell.textField.text forKey:@"nickname"];
    [dic setObject:self.departmentCell.textField.text forKey:@"department"];
    [dic setObject:self.positionCell.textField.text forKey:@"position"];
//    [dic setObject:phoneCell.textField.text forKey:@"telephone"];
    [dic setObject:self.emailCell.textField.text forKey:@"email"];
    [dic setObject:self.companyCell.textField.text forKey:@"company_name"];
    [dic setObject:((self.wxQRCodeCell.textField.text.length)?(self.wxQRCodeCell.textField.text):@"") forKey:@"weixin"];
    [dic setObject:(pathWXImg?pathWXImg:@"") forKey:@"weixin_img"];
    __weak __typeof(self)weakSelf = self;
    [BaseNetManager requestWithMethod:POST path:Company_CreateBaseInfo_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            UD_SetOForK(data[@"company_id"], isCompanyID);
            UDSynchronize;
            [DataToolsControl getMyBaseInfoForCompany:^(BOOL requestFlag) {
                SVPHUDDismiss;
                if (!requestFlag) {
                    if (self.companyCell.textField.text && self.companyCell.textField.text.length) {
                        UD_SetOForK(data[@"company_id"], isCompanyName);
                    }
                    UDSynchronize;
                }
                CompanySecondInfoViewController *CSIVC = [[CompanySecondInfoViewController alloc] init];
                CSIVC.companyName = strongSelf.companyCell.textField.text;
                [strongSelf.navigationController pushViewController:CSIVC animated:YES];
            }];
//            id data = responseObject[@"data"];
//            SVPHUDDismiss;
//            UD_SetOForK(data[@"company_id"], isCompanyID);
//            if (self.companyCell.textField.text && self.companyCell.textField.text.length) {
//                UD_SetOForK(data[@"company_id"], isCompanyName);
//            }
//            UDSynchronize;
//            CompanySecondInfoViewController *CSIVC = [[CompanySecondInfoViewController alloc] init];
//            CSIVC.companyName = strongSelf.companyCell.textField.text;
//            [strongSelf.navigationController pushViewController:CSIVC animated:YES];
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
//    [UIToolsControl resignFirstResponderForTextFieldArray:@[nameCell.textField, nicknameCell.textField, departmentCell.textField, positionCell.textField, phoneCell.textField, emailCell.textField, companyCell.textField]];
    [UIToolsControl resignFirstResponderForTextFieldArray:@[self.nameCell.textField, self.nicknameCell.textField, self.departmentCell.textField, self.positionCell.textField, self.emailCell.textField, self.companyCell.textField]];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    if (bottomScrollView.contentOffset.y != 0) {
        [UIView animateWithDuration:KeyboardAnimationTime animations:^{
            self->bottomScrollView.contentOffset = CGPointMake(0, 0);
        }];
    }
    return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    if ((self.nameCell.textField == textField) || (self.nicknameCell.textField == textField) || (self.departmentCell.textField == textField)) {
        if (bottomScrollView.contentOffset.y != 0) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 0);
            }];
        }
    } else if (isiPhone5 || isiPhone6) {
        if (textField == self.positionCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale+30*Scale);
            }];
        }
//        else if (textField == phoneCell.textField) {
//            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
//                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*2+30*Scale);
//            }];
//        }
        else if (textField == self.emailCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*3+30*Scale);
            }];
        } else if (textField == self.companyCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*4+30*Scale);
            }];
        }
    } else {
        if (textField == self.positionCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale);
            }];
        }
//        else if (textField == phoneCell.textField) {
//            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
//                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*2);
//            }];
//        }
        else if (textField == self.emailCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*3);
            }];
        } else if (textField == self.companyCell.textField) {
            [UIView animateWithDuration:KeyboardAnimationTime animations:^{
                self->bottomScrollView.contentOffset = CGPointMake(0, 75*Scale*4);
            }];
        }
    }
    return YES;
}


- (void)mineInfoEditWXQRCodeViewControllerInfo:(NSString *)wxID {
    self.wxQRCodeCell.textField.text = wxID;
}
- (void)mineInfoEditWXQRCodeViewControllerInfoWXImgPath:(NSString *)wxID {
    pathWXImg = wxID;
}
- (void)photoBtnTap {
    headerPickerView.hidden = NO;
}
- (void)psSingleRowViewCancel:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
}
- (void)psSingleRowViewOk:(PublicCategoryElementModel *)model PSSingleRowView:(PSSingleRowView *)psSingleRowView {
    psSingleRowView.hidden = YES;
    if ([model.id integerValue] == 1) { // 相册
        [self openPhotoLibrary];
    } else { // 拍摄
        [self openCamera];
    }
}
- (void)openCamera {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = YES;
    
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if (status == AVAuthorizationStatusRestricted || status == AVAuthorizationStatusDenied) { // 无权限
        CustomView *alertView = [[CustomView alloc] initWithTitle:@"相机权限未开启" message:@"相机权限未开启，请进入系统【设置】>【隐私】>【相机】中打开开关,开启相机功能" prompt:nil sureBtn:@"确定" cancleBtn:@"取消" size:170];
        alertView.resultIndex = ^(NSInteger index) { //回调---处理一系列动作
            if (index == 2) {
                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
            }
        };
        [alertView showXLAlertView];
    } else { // 有权限
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentViewController:picker animated:YES completion:nil];
    }
}
- (void)openPhotoLibrary {
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusRestricted || status == PHAuthorizationStatusDenied) { // 无权限
        CustomView *alertView = [[CustomView alloc] initWithTitle:@"相册权限未开启" message:@"相册权限未开启，请进入系统【设置】>【隐私】>【相册】中打开开关,开启相册功能" prompt:nil sureBtn:@"确定" cancleBtn:@"取消" size:170];
        alertView.resultIndex = ^(NSInteger index) { //回调---处理一系列动作
            if (index == 2) {
                [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
            }
        };
        [alertView showXLAlertView];
    } else { // 有权限
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.allowsEditing = YES;
        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.delegate = self;
        imagePicker.navigationBar.translucent = NO;
        imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
        [self presentViewController:imagePicker animated:YES completion:^{
            NSLog(@"打开相册");
        }];
    }
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
    NSLog(@"finish..");
    UIImage *image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
    SVPHUDShow;
    [DataToolsControl uploadImgType:UploadImgTypeOfHeader image:image successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            self->url = data[@"url"];
            self->photoImgView.image = image;
            SVPHUDDismiss;
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(@"上传失败，请重新操作");
    }];
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)switchBtnTap {
    NSLog(@"切换角色");
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:@"2" forKey:@"user_role"];
    [BaseNetManager requestWithMethod:POST path:Change_Role_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            UD_SetOForK(@"2", isUserRole);
            
            NSDictionary *data = responseObject[@"data"];
            if (data[@"user_guide"] && [data[@"user_guide"] length] && ([data[@"user_guide"] isEqualToString:@"choose_role"])) { // 用户还没选角色 （选择用户角色）
                IDSelectViewController *IDSVC = [[IDSelectViewController alloc] init];
                IDSVC.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:IDSVC animated:NO];
            } else {
                if ([data[@"user_guide"] isEqualToString:@"company_add_job"]) { // 添加工作
                    [DataToolsControl getMyBaseInfoForCompany:^(BOOL requestFlag) {
                        [SharedApp showViewController:TabBarTypeOfCompany];
                        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
                        tabBarController.selectedIndex = 1;
                    }];
                } else if ([data[@"user_guide"] isEqualToString:@"company_create"]) { // 招聘者下面没有企业的话就会引导创建
                    CompanyFirstInfoViewController *IDSVC = [[CompanyFirstInfoViewController alloc] init];
                    IDSVC.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:IDSVC animated:NO];
                } else if ([data[@"user_guide"] isEqualToString:@"company_info"]) { // 填写企业信息
                    CompanySecondInfoViewController *IDSVC = [[CompanySecondInfoViewController alloc] init];
                    IDSVC.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:IDSVC animated:NO];
                } else if ([data[@"user_guide"] isEqualToString:@"company_audit"]) { // 企业未认证
                    SVPHUDShow;
                    [DataToolsControl getMyBaseInfoForCompany:^(BOOL requestFlag) {
                        SVPHUDDismiss;
                        [SharedApp showViewController:TabBarTypeOfCompany];
                        UITabBarController *tabBarController = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
                        tabBarController.selectedIndex = tabBarController.viewControllers.count-1;
                        UINavigationController *navigationController = (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController;
                        
                        CompanyInfoViewController *CIVC = [[CompanyInfoViewController alloc] init];
                        CIVC.hidesBottomBarWhenPushed = YES;
                        [navigationController pushViewController:CIVC animated:YES];
                    }];
                } else if (([data[@"user_guide"] isEqualToString:@"resume_create"])) { // 创建简历页
                    PersonalFirstInfoViewController *PMRVC = [[PersonalFirstInfoViewController alloc] init];
                    PMRVC.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:PMRVC animated:NO];
                } else if ([data[@"user_guide"] isEqualToString:@"resume_edu"]) { // 完善简历中教育经历
                    if (data[@"is_graduate"] && ([data[@"is_graduate"] integerValue] == 0)) {
                        [DataToolsControl sharedManager].idType = IDTypeOfWorker;
                    } else {
                        [DataToolsControl sharedManager].idType = IDTypeOfFreshGraduate;
                    }
                    
                    PersonalEducationInfoViewController *PMRVC = [[PersonalEducationInfoViewController alloc] init];
                    PMRVC.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:PMRVC animated:NO];
                } else if ([data[@"user_guide"] isEqualToString:@"resume_work"]) { // 完善简历中工作经历
                    PersonalWorkExperienceViewController *PMRVC = [[PersonalWorkExperienceViewController alloc] init];
                    PMRVC.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:PMRVC animated:NO];
                } else {
                    [DataToolsControl getMyBaseInfoForWorker:^(BOOL requestFlag) {
                        [SharedApp showViewController:TabBarTypeOfPersonal];
                    }]; 
                }
            }
        } else {
            SVPHUDError(responseObject[@"msg"]);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)hiddenKeyboard {
//    [UIToolsControl resignFirstResponderForTextFieldArray:@[nameCell.textField, nicknameCell.textField, departmentCell.textField, positionCell.textField, phoneCell.textField, emailCell.textField, companyCell.textField]];
    [UIToolsControl resignFirstResponderForTextFieldArray:@[self.nameCell.textField, self.nicknameCell.textField, self.departmentCell.textField, self.positionCell.textField, self.emailCell.textField, self.companyCell.textField]];
}
- (void)customBackButtonTap {
    [self.navigationController popViewControllerAnimated:YES];
}

@end
